package com.vandzi.android.androidcode;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TabHost;
import android.widget.TextView;

public class AndroidCode2011Activity extends TabActivity {
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		TabHost tabHost = getTabHost(); // The activity TabHost
		TabHost.TabSpec spec; // Resusable TabSpec for each tab
		Intent intent; // Reusable Intent for each tab

		// Initialize a TabSpec for each tab and add it to the TabHost

		View homeTitle = (View) LayoutInflater.from(this).inflate(
				R.layout.tabtitle, null);
		TextView tabTitle = (TextView) homeTitle.findViewById(R.id.textView1);

		// Create an Intent to launch an Activity for the tab (to be reused)
		// HOME TAB
		intent = new Intent().setClass(this, HomeActivity.class);
		tabTitle.setText(getText(R.string.home));
		spec = tabHost.newTabSpec("home").setIndicator(homeTitle)
				.setContent(intent);
		tabHost.addTab(spec);

		// APPLICATIONS TAB
		intent = new Intent().setClass(this, ApplicationsListActivity.class);
		homeTitle = (View) LayoutInflater.from(this).inflate(R.layout.tabtitle,
				null);
		tabTitle = (TextView) homeTitle.findViewById(R.id.textView1);
		tabTitle.setText(getText(R.string.applications));
		spec = tabHost.newTabSpec("apps").setIndicator(homeTitle)
				.setContent(intent);
		tabHost.addTab(spec);

		// PRIZES TAB
		intent = new Intent().setClass(this, PrizesActivity.class);
		homeTitle = (View) LayoutInflater.from(this).inflate(R.layout.tabtitle,
				null);
		tabTitle = (TextView) homeTitle.findViewById(R.id.textView1);
		tabTitle.setText(getText(R.string.prizes));
		spec = tabHost.newTabSpec("prizes").setIndicator(homeTitle)
				.setContent(intent);
		tabHost.addTab(spec);

		// JUDGES TAB
		intent = new Intent().setClass(this, JudgesActivity.class);
		homeTitle = (View) LayoutInflater.from(this).inflate(R.layout.tabtitle,
				null);
		tabTitle = (TextView) homeTitle.findViewById(R.id.textView1);
		tabTitle.setText(getText(R.string.judges));
		spec = tabHost.newTabSpec("judges").setIndicator(homeTitle)
				.setContent(intent);
		tabHost.addTab(spec);

		// RULES TAB
		intent = new Intent().setClass(this, RulesActivity.class);
		homeTitle = (View) LayoutInflater.from(this).inflate(R.layout.tabtitle,
				null);
		tabTitle = (TextView) homeTitle.findViewById(R.id.textView1);
		tabTitle.setText(getText(R.string.rules));
		spec = tabHost.newTabSpec("rules").setIndicator(homeTitle)
				.setContent(intent);
		tabHost.addTab(spec);

		
		tabHost.setCurrentTab(0);
	}
}